import * as types from '../mutation-types';
import { fetch } from 'utils/api.js';

const state = {
  loading: false,
  columnList: []
};

const mutations = {
  [types.SET_COLUMN_LIST](state, columnList) {
    state.columnList = columnList;
  }
};

const actions = {
  loadColumnList({ commit, state }) {
    fetch('specialColumnList').then((res) => {
      if (res.code === 200) {
        commit(types.SET_COLUMN_LIST, res.data);
      } else {
        throw new Error('Response Error');
      }
    });
  }
};

export default {
  state,
  mutations,
  actions
};
